import {h} from 'vue';
import SvgIcon from './index.vue';
import {useMessage} from '/@/hooks/message';

export const useIconRender=()=>{
   interface IconConfig {
    icon?: string;
    color?: string;
    fontSize?: number;
    iconif?: boolean;
  }

  const iconRender=(config:IconConfig)=>{
     const {
          color = '',
          fontSize = 16,
          icon = '',
          iconif = true
        } = config;

        if(!icon){
            useMessage.warning('iconRender: icon is required');
        }
        return () => h(SvgIcon, { name:icon, color:color,size:fontSize,iconify:iconif });
   }

  return {
    iconRender,
  };
}